Skip to content

Fix handling of multiple block macros in the same with statement#22

Open
Technologicat wants to merge 2 commits intoazazel75:masterfrom
Technologicat:withfix2
Open

Fix handling of multiple block macros in the same with statement#22
Technologicat wants to merge 2 commits intoazazel75:masterfrom
Technologicat:withfix2

Conversation

@Technologicat
Copy link

See issue #21 for details.

… ordering), even if new_tree completely replaces in_tree.body
@azazel75
Copy link
Owner

Can you please add a testcase for this? thanks

@Technologicat
Copy link
Author

Sure, I'll add a test for this too.

Since I originally posted this PR, I've discovered that my fix still doesn't handle the fully general case correctly, but I haven't had time to investigate it further or to create a minimal example that reproduces the bug.

What I've noticed is problems may occur with two-pass macros (that both yield and return stuff), for an example see namedlambda in unpythonic.syntax. (The macro itself works fine, when using a separate with block for it.)

…here the inner macro returns a completely new tree
@Technologicat
Copy link
Author

Here's a test for the basic case for two block macros in the same with, where both macros operate only in the second pass.

I think the more complex cases could be handled at some later time?

@Technologicat
Copy link
Author

Ping? Need more complex test cases, or is this fine now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments